<%inherit file="./base.html" />
<%def name="css()">
.detail {margin-top:80px;font:25px "Comic Sans MS",Arial,Helvetica,sans-serif;}
.detail p {margin-top:20px;}
.download-info {padding-bottom:150px;}
.download-btn {float:right;}
td.download-sel {text-align:center;}
</%def>
<%def name="mbody()">
<div class="detail hero-unit">
    <h2>${subject.name}</h2>
    <p>${subject.intro}</p>
</div>
% if downloads:
<div class="download-info">
    <table class="table">
        <thead>
            <td class="download-sel all"><input type="checkbox" checked="checked"></td>
            <td> </td>
            <td> </td>
        </thead>
        <tbody>
        % for d in downloads:
        <tr>
            <td class="download-sel" ><input type="checkbox" checked="checked"></td>
            <td><a href="${d.url}">${d.url_title}</a></td>
            <td>${d.size}</td>
        </tr>
        % endfor
        </tbody>
    </table>
    <button class="download-btn btn btn-success" href="#">下载</button>
</div>
% endif
</%def>

<%def name="js()">
$(document).ready(function(){
    //全选
    $('.all').click(function(){
        var checked = $('.all input:checkbox').prop('checked');
        $('.download-sel input:checkbox').prop('checked', checked);
    });

    //复制下载链接
    $(".download-btn").zclip({
        path: "/static/swf/ZeroClipboard.swf",
        copy: function(){
            var download_urls = '';
            $('.download-sel input:checkbox').each(function(i){
                var $this = $(this);
                if($this.parent().hasClass('all') || !$this.prop('checked')){
                    return;
                }
                var url = $this.parent().siblings().find('a').prop('href');
                download_urls += url;
                download_urls += '\n';
            });
            return download_urls
        }
    });
});
</%def>

<%def name="more_header()">
    <script src="/static/js/lib/jquery.zclip.min.js"></script>
</%def>
